# coding:utf-8
"""
@author: jing
@contact: 529548204@qq.com
@file: datasTypeChange.py
@time: 2022/5/11 15:05
"""


def valuehandle(data: str):
    """
    url格式字符串转化成字典
    url的param参数转化为字典
    :param data:
    :return:
    """
    param_dict = {}
    param_list = data.split("&")
    for param in param_list:
        param_dict[param.split("=")[0]] = param.split("=")[1]
    return param_dict


def strhandlecookies(data: dict):
    """
    字典转化成字符串
    :param data:
    :return:
    """
    cookies_str = ''
    for k, v in data.items():
        cookies_str = cookies_str + (k + "=" + str(v) + ";")
    return cookies_str


def strhandleurl(data: dict):
    """
    字典转化成字符串
    :param data:
    :return:
    """
    url_str = ''
    for k, v in data.items():
        url_str = url_str + (k + "=" + str(v) + "&")
    return url_str.strip("&")


if __name__ == '__main__':
    d = {
        "a": 1,
        "b": 2
    }
    print(strhandleurl(d))
